home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 April / EnigmA AMIGA RUN 17 (1997)(G.R. Edizioni)(IT)[!][issue 1997-04][EAR-CD].iso / EARCD / text / hyper / hsc_source.lha / hsc / source / ugly / fname.h < prev    next >
C/C++ Source or Header  |  1996-10-27  |  3KB  |  132 lines

  1. /*
  2.  *
  3.  * fname.h
  4.  *
  5.  * header file for filename manipulaton functions
  6.  *
  7.  * (W) by Tommy-Saftwörx in 1994,95,96
  8.  *
  9.  */
  10.  
  11. #ifndef UGLY_FNAME_H
  12. #define UGLY_FNAME_H
  13.  
  14. #include "utypes.h"
  15. #include "expstr.h"
  16.  
  17. /*
  18.  * system depandant defines
  19.  */
  20.  
  21. /*
  22.  * MAX_FPATH         max. length of whole path
  23.  * MAX_FNAME         max. length of filename
  24.  * MAX_FEXT          max. length of file extension
  25.  * PATH_SEPARATOR    to separate diretories and devices
  26.  * DIR_SEPARATOR     to separate directories
  27.  * PARENT_DIR        to be inserted to refer to parent directory
  28.  * FNAME_IGNORE_CASE flag; ignore case within filenames
  29.  *
  30.  * CRLF_SHIT         0=OS uses single "\n" for EOL
  31.  */
  32.  
  33. #ifdef AMIGA
  34. #define MAX_FPATH 256
  35. #define MAX_FNAME  31
  36. #define MAX_FEXT   30
  37. #define PATH_SEPARATOR    "/:"
  38. #define DIR_SEPARATOR     '/'
  39. #define PARENT_DIR        "/"
  40. #define FNAME_IGNORE_CASE 1
  41. #define SUGGEST_CRLF_SHIT 0
  42.  
  43. #elif defined BEBOX
  44. #define MAX_FPATH 254
  45. #define MAX_FNAME  64
  46. #define MAX_FEXT   63
  47. #define PATH_SEPARATOR    "/"
  48. #define DIR_SEPARATOR     '/'
  49. #define PARENT_DIR        "../"
  50. #define FNAME_IGNORE_CASE 1
  51. #define SUGGEST_CRLF_SHIT 0
  52.  
  53. #elif defined UNIX
  54. #define MAX_FPATH 254
  55. #define MAX_FNAME 254
  56. #define MAX_FEXT  253
  57. #define PATH_SEPARATOR    "/"
  58. #define DIR_SEPARATOR     '/'
  59. #define PARENT_DIR        "../"
  60. #define FNAME_IGNORE_CASE 0
  61. #define SUGGEST_CRLF_SHIT 0
  62.  
  63. #elif defined WINNT
  64. #define MAX_FPATH 254
  65. #define MAX_FNAME 254
  66. #define MAX_FEXT  253
  67. #define PATH_SEPARATOR    "\\:"
  68. #define DIR_SEPARATOR     '\\'
  69. #define PARENT_DIR        "..\\"
  70. #define FNAME_IGNORE_CASE 1
  71. #define SUGGEST_CRLF_SHIT 1
  72.  
  73. #define MSDOS 1 /* isn't this nasty? */
  74.  
  75. #elif defined MSDOS
  76. #define MAX_FPATH 128
  77. #define MAX_FNAME   8
  78. #define MAX_FEXT    3
  79. #define PATH_SEPARATOR    "\\:"
  80. #define DIR_SEPARATOR     '\\'
  81. #define PARENT_DIR        "..\\"
  82. #define FNAME_IGNORE_CASE 1
  83. #define SUGGEST_CRLF_SHIT 1
  84.  
  85. #else
  86. #error "Operating system not supported: filename-functions"
  87. #endif
  88.  
  89. /* if CRLF_SHIT has not been set by user, use OS-default */
  90. #ifndef CRLF_SHIT
  91. #define CRLF_SHIT SUGGEST_CRLF_SHIT
  92. #endif
  93.  
  94. /* strcmp() for filenames: case-sensitive or not */
  95. #if FNAME_IGNORE_CASE
  96. #define fnamecmp(a,b) strcmp((a),(b))
  97. #define fnamencmp(a,b,n) strncmp((a),(b),(n))
  98. #else
  99. #define fnamecmp(a,b) upstrcmp((a),(b))
  100. #define fnamencmp(a,b,n) upstrncmp((a),(b),(n))
  101. #endif
  102.  
  103. #define ok_fnl_fpath(x) ((BOOL)(estrlen(x)<=MAX_FPATH))
  104. #define ok_fnl_fname(x) ((BOOL)(estrlen(x)<=MAX_FNAME))
  105. #define ok_fnl_fext(x)  ((BOOL)(estrlen(x)<=MAX_FEXT))
  106.  
  107. /*
  108.  * external function prototypes
  109.  */
  110.  
  111. #ifndef NOEXTERN_UGLY_FNAME_H
  112.  
  113. extern BOOL get_fext(EXPSTR * dest, CONSTRPTR fn);
  114. extern BOOL get_fname(EXPSTR * dest, CONSTRPTR fn);
  115. extern BOOL get_fpath(EXPSTR * dest, CONSTRPTR fn);
  116. extern BOOL get_fsdir(EXPSTR * dest, CONSTRPTR fn);
  117. extern BOOL get_relfname(EXPSTR * dest, STRPTR absn, STRPTR curp);
  118.  
  119. extern BOOL clr_fext(EXPSTR * dest);
  120. extern BOOL set_fext(EXPSTR * dest, CONSTRPTR newext);
  121. extern BOOL app_fext(EXPSTR * dest, CONSTRPTR newext);
  122. extern BOOL set_fnameIdx(EXPSTR * dest, int idx);
  123. extern BOOL link_fname(EXPSTR * dest, STRPTR dir, STRPTR fn);
  124. extern BOOL link_envfname(EXPSTR * dest, STRPTR env, STRPTR dir, STRPTR fn);
  125.  
  126. extern STRPTR tmpnamstr(STRPTR prefix);
  127.  
  128. #endif
  129.  
  130. #endif
  131.  
  132.